﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _14_Observer
{
    /*
     * 秘书类
     */
    class Secretary
    {
        private IList<StockObserver> observers = new List<StockObserver>();
        private string action;

        public void Attach(StockObserver observer)
        {
            observers.Add(observer);
        }

        public void Notify()
        {
            foreach (var observer in observers)
            {
                observer.Update();
            }
        }
    }

    class StockObserver
    {
        private string name;

        public StockObserver(string name)
        {
            this.name = name;
        }

        public void Update()
        {
            Console.WriteLine("{0} 收到 前台消息，开始干活！", name);
        }
    }
}
